package com.example.lenovo.myapplication;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class MyBroadcastReceiver extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals("Weather_Report")) {

            String weather = intent.getStringExtra("Weather");
            int temp = intent.getIntExtra("temprature", 0);
            Log.e("MyBroadcastReceiver", "收到广播，天气" + weather + "温度" + temp);
        }else if(action.equals("Trafic_Report")){

            String trafic=intent.getStringExtra("Trafic");
            int time =intent.getIntExtra("Time",0);
            Log.e("MyBroadcastReceiver","收到交通广播,"
                    +trafic +"时间"+time);

        }

    }
}
